package com.suypower.carManage.action;

import javax.servlet.ServletException;

import com.jarp.db.DAO;
import com.opensymphony.xwork2.ActionSupport;
import com.suypower.carManage.comm.ConstUtil;

public class RechargeAction extends ActionSupport {

	private String car_code;
	private String card_code;
	private String recharge_date;
	private String recharge_money;
	private String recharge_last;
	private String recharge_later;
	private String remark;
	private String id;

	public String getCar_code() {
		return car_code;
	}

	public void setCar_code(String carCode) {
		car_code = carCode;
	}

	public String getCard_code() {
		return card_code;
	}

	public void setCard_code(String cardCode) {
		card_code = cardCode;
	}

	public String getRecharge_date() {
		return recharge_date;
	}

	public void setRecharge_date(String rechargeDate) {
		recharge_date = rechargeDate;
	}

	public String getRecharge_money() {
		return recharge_money;
	}

	public void setRecharge_money(String rechargeMoney) {
		recharge_money = rechargeMoney;
	}

	public String getRecharge_last() {
		return recharge_last;
	}

	public void setRecharge_last(String rechargeLast) {
		recharge_last = rechargeLast;
	}

	public String getRecharge_later() {
		return recharge_later;
	}

	public void setRecharge_later(String rechargeLater) {
		recharge_later = rechargeLater;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String execute() {
		String res = "";
		DAO dao = new DAO();
		String sql="";
		if(id!=null&&!id.equals("")){
			sql="UPDATE tb_refuel_card_recharge SET  car_code = '"+car_code+"', card_code = '"+card_code+"', recharge_date = '"+recharge_date+"', recharge_money = '"+recharge_money+"', recharge_last = '"+recharge_last+"', recharge_later = '"+recharge_later+"', remark = '"+remark+"' where id="+id; 
		}else{
			sql = "INSERT INTO tb_refuel_card_recharge(car_code,card_code,recharge_date,recharge_money,recharge_last,recharge_later,remark)VALUES('"
				+ car_code
				+ "','"
				+ card_code
				+ "','"
				+ recharge_date
				+ "',"
				+ recharge_money
				+ ","
				+ recharge_last
				+ ","
				+ recharge_later
				+ ",'" + remark + "')";
		}
		
		int count = 0;
		try {
			count=dao.execCommand(ConstUtil.DBNAME, sql);
			if(count>0){
				res=this.SUCCESS;
			}else{
				res=this.ERROR;
			}
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res;
	}
}
